{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import torch\n",
    "from TTS.api import TTS\n",
    "\n",
    "# Get device\n",
    "device = \"cuda\" if torch.cuda.is_available() else \"cpu\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/Users/thebitanpaul/Library/CloudStorage/GoogleDrive-thebitanpaul@gmail.com/My Drive/Classroom/Data Science(2024)/Evaluation Project/Linguistic/lib/python3.9/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
      "  from .autonotebook import tqdm as notebook_tqdm\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "'output.wav'"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Init TTS\n",
    "tts = TTS(\"tts_models/multilingual/multi-dataset/xtts_v2\").to(device)\n",
    "\n",
    "# Run TTS\n",
    "# Since this model is multi-lingual voice cloning model, we must set the target speaker_wav and language\n",
    "# Text to speech list of amplitude values as output\n",
    "# wav = tts.tts(text=\"Hello world!\", speaker_wav=\"/Users/thebitanpaul/Library/CloudStorage/GoogleDrive-thebitanpaul@gmail.com/My Drive/Classroom/Data Science(2024)/Evaluation Project/PolyMath/coqui-ai-TTS/bark_voices/speaker/Trimmed.wav\", language=\"en\")\n",
    "# Text to speech to a file\n",
    "tts.tts_to_file(text=\"My name is Bitan Paul. I am an artificial intelligence specialist.\", speaker_wav=\"/Users/thebitanpaul/Library/CloudStorage/GoogleDrive-thebitanpaul@gmail.com/My Drive/Classroom/Data Science(2024)/Evaluation Project/Linguistic/bark_voices/speaker/short.wav\", language=\"en\", file_path=\"output.wav\")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Linguistic",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.19"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
